Java_Q and A 2023
What is Java Beans?
Java Beans are reusable components. It is a class having no-argument constructor with getter and setter methods for its attributes; the class implements Serializable interface.
How are Java beans class used in JSP?
Following tags are used to access Java Beans in JSP:
What are the JSP elements?
What are JSP Directives?
JSP directives tell web container about translating JSP to corresponding servlet. There are three types of JSP directives:
How is session set and retrieved in JSP?
Setting session: session.setAttribute("name of attribute", "value of attribute");
Retrieving session: session.getAttribute("name of attribute");
What is servlet
Servlet is a technology to create web applications, is a class that extends capabilities of web server
How is servlet created?
Servlet can be created using anyone of following methods:
How is servlet different from CGI?
CGI (common gateway interface) is a technology to handle client requests. In this technology, enables server to call
external program to process the HTTP request information. Each request is handles by separate process.
Servlet performs better than CGI, it is protable and secure as it is written in Java. Servlet creates thread to handle each
HTTP request.
What are the parameters passed to doGet or doPost method of servlet class?
Parametes are: HttpServletRequest object, and HttpServletResponse object
Which exceptions need to be handled by servlet?
Exceptions thrown: ClassNotFoundException, ServletException, FileNotFoundException
How is servlet deployed in apache tomcat?
Create folder for web application inside webapps folder of apache tomcat webserver. Inside that folder create folders: src, lib, classes and a web.xml (deployment descriptor) file. Inside src folder store Java classes. Inside classes folder save complied Java Classes. In the web.xml (deployment descriptor) specify name of servlet, servlet class, url pattern. Web.xml is an xml file containing information about the servlet.